<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 特殊数组的特征值 -->
    <script>
      var specialArray = function (nums) {
        nums.sort((a, b) => b - a)
        let res = -1
        for (let i = 0; i < nums.length; i++) {
          if (nums[i] >= i + 1 && (nums[i + 1] || -1) < i + 1) res = i + 1
        }
        return res
      }
      console.log(specialArray([3, 5]))
    </script>
  </body>
</html>
